<?php require_once('../connections/con_gl.php'); ?>
<?php
$act = $_GET[act];
$url = "index.php?component=transaksicheckinout";
$ope = $_POST['open'];

/* Validasi */
if (trim($_POST['nopolisi']) == '') {
	$error[] = '- No. Polisi harus diisi';
}

/*End validasi */
if (isset($error)) {
	echo "<img src=\"images/alert.png\" width=\"16\" align=\"left\"/>&nbsp;&nbsp;<b style=\"color:red;\">Error : </b> <br />".implode("<br />", $error);
}else{
	if($act =='add') {
	$query = "INSERT INTO gl_transaksicheckinout (id, nopolisi, noreferensi, tglcheckinout, jamcheckinout, jenistransaksi, kondmesin1, kondmesin2, kondrem1, kondrem2, kondkopling1, kondkopling2, kondban1, kondban2, kondac1, kondac2, kondsen1, kondsen2, kondlampu1, kondlampu2, kondlampurem1, kondlampurem2, kondrad1, kondrad2, kondolimesin1, kondolimesin2, kondolistreering1, kondolistreering2, kondinterior1, kondinterior2, kondbodi1, kondbodi2, bancad1, bancad2, dongkrak1, dongkrak2, kunciroda1, kunciroda2, radio1,radio2, karpet1, karpet2, doproda1, doproda2, pematikapi1, pematikapi2, segitiga1, segitiga2, kotakobat1, kotakobat2, stnk1, stnk2, deposit1, deposit2, kuncipintu1, kuncipintu2) VALUES (NULL, '$_POST[nopolisi]', '$_POST[noreferensi]', '$_POST[tglcheckinout]', '$_POST[jamcheckinout]', '$_POST[RadioGroup0]','$_POST[RadioGroup1]', '$_POST[RadioGroup2]', '$_POST[RadioGroup3]', '$_POST[RadioGroup4]', '$_POST[RadioGroup5]', '$_POST[RadioGroup6]', '$_POST[RadioGroup7]', '$_POST[RadioGroup8]', '$_POST[RadioGroup9]', '$_POST[RadioGroup10]', '$_POST[RadioGroup11]', '$_POST[RadioGroup12]', '$_POST[RadioGroup13]', '$_POST[RadioGroup14]', '$_POST[RadioGroup15]', '$_POST[RadioGroup16]', '$_POST[RadioGroup17]', '$_POST[RadioGroup18]', '$_POST[RadioGroup19]', '$_POST[RadioGroup20]', '$_POST[RadioGroup21]', '$_POST[RadioGroup22]', '$_POST[RadioGroup23]', '$_POST[RadioGroup24]', '$_POST[RadioGroup25]', '$_POST[RadioGroup26]', '$_POST[RadioGroup27]', '$_POST[RadioGroup28]', '$_POST[RadioGroup29]', '$_POST[RadioGroup30]', '$_POST[RadioGroup31]', '$_POST[RadioGroup32]', '$_POST[RadioGroup33]', '$_POST[RadioGroup34]', '$_POST[RadioGroup35]', '$_POST[RadioGroup36]', '$_POST[RadioGroup37]', '$_POST[RadioGroup38]', '$_POST[RadioGroup39]', '$_POST[RadioGroup40]', '$_POST[RadioGroup41]', '$_POST[RadioGroup42]', '$_POST[RadioGroup43]', '$_POST[RadioGroup44]', '$_POST[RadioGroup45]', '$_POST[RadioGroup46]', '$_POST[RadioGroup47]', '$_POST[RadioGroup48]', '$_POST[RadioGroup49]', '$_POST[RadioGroup50]', '$_POST[RadioGroup51]', '$_POST[RadioGroup52]')";
	}else if($act=='edit'){
	$query ="UPDATE gl_transaksicheckinout SET nopolsi='$_POST[nopolisi]', noreferensi='$_POST[noreferensi]', tglcheckinout='$_POST[tglcheckinout]', jamcheckinout='$_POST[jamcheckinout]', jenistransaksi='$_POST[RadioGroup0]' WHERE id='$_POST[id]'";
	}else{
	$query = "delete from gl_transaksicheckinout where id='$_POST[id]'";
	}
	mysql_select_db($database_con_gl, $con_gl);
	$runquery = mysql_query($query, $con_gl);
	if($runquery) {
		echo "<img src=\"images/ok.png\" align=\"left\" width=\"16\">&nbsp;&nbsp;Data berhasil ";if($act=='add' OR $act=='edit') { echo "disimpan";}else{ echo "dihapus"; } echo " ...";
	}else{
		echo "<img src=\"images/alert.png\" align=\"left\" width=\"16\"> Data gagal disimpan !!!";
	}
}
?>
<?php if($runquery AND $ope=='window') { ?>
	<script type="text/javascript">top.opener.sendRespondKelompok();self.close(2000);</script>
<?php }else if($runquery AND $ope==''){ ?>
	<script type="text/javascript">setTimeout("location.href='<?php echo $url;?>'", 2000);</script>
<?php } ?>